﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace YitWeb.Common
{
    public class PageInfo
    {
        public int PageSize { get; set; }
        public int PageIndex { get; set; }

        public int RecordCount { get; set; }

        public int PageCount
        {
            get
            {
                return (RecordCount - 1) / PageSize + 1;
            }
        }

        public int PageStart
        {
            get
            {
                return PageSize * PageIndex;
            }
        }

        public PageInfo<T> Result<T>(List<T> list, int recordCount)
        {
            PageInfo<T> page = new PageInfo<T>();
            page.PageSize = this.PageSize;
            page.PageIndex = this.PageIndex;
            page.List = list;
            page.RecordCount = recordCount;
            return page;
        }
    }

    public class PageInfo<T> : PageInfo
    {
        public List<T> List { get; set; }
    }
}
